package com.lwz.repair.controller;

import com.alibaba.fastjson.JSONObject;
import com.lwz.repair.entity.User;
import com.lwz.repair.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/repair")
@RestController
public class Usercontroller {

    @Autowired
    UserService userService;

    @PostMapping("/login")
    public String Login(@RequestBody JSONObject req){
        String username =req.getString("username");
        String password =req.getString("password");
        System.out.println(username);
        System.out.println(password);

        User user = userService.Login(username,password);

        if (user!=null){
            return "success";
        }else {
            return "flase";
        }
    }



}
